package com.ruoyi.project.module.whd.kaipai;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.project.domain.YqgSetMeal;
import com.ruoyi.project.service.IYqgSetMealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 套餐信息Controller
 * 
 * @author ruoyi
 * @date 2023-08-15
 */
@RestController
@RequestMapping("/whd/meal")
public class WhdSetMealController extends BaseController
{
    @Autowired
    private IYqgSetMealService yqgSetMealService;

    /**
     * 查询套餐信息列表
     */
   /* @RequiresPermissions("project:meal:list")*/
    @GetMapping("/list")
    public TableDataInfo list(YqgSetMeal yqgSetMeal)
    {
        startPage();
        List<YqgSetMeal> list = yqgSetMealService.selectYqgSetMealList(yqgSetMeal);
        return getDataTable(list);
    }

    /**
     * 导出套餐信息列表
     */
    /*@RequiresPermissions("project:meal:export")*/
    @Log(title = "套餐信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqgSetMeal yqgSetMeal)
    {
        List<YqgSetMeal> list = yqgSetMealService.selectYqgSetMealList(yqgSetMeal);
        ExcelUtil<YqgSetMeal> util = new ExcelUtil<YqgSetMeal>(YqgSetMeal.class);
        util.exportExcel(response, list, "套餐信息数据");
    }

    /**
     * 获取套餐信息详细信息
     */
    /*@RequiresPermissions("project:meal:query")*/
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yqgSetMealService.selectYqgSetMealById(id));
    }

    /**
     * 新增套餐信息
     */
   /* @RequiresPermissions("project:meal:add")*/
    @Log(title = "套餐信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqgSetMeal yqgSetMeal)
    {
        return toAjax(yqgSetMealService.insertYqgSetMeal(yqgSetMeal));
    }

    /**
     * 修改套餐信息
     */
    /*@RequiresPermissions("project:meal:edit")*/
    @Log(title = "套餐信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqgSetMeal yqgSetMeal)
    {
        return toAjax(yqgSetMealService.updateYqgSetMeal(yqgSetMeal));
    }

    /**
     * 删除套餐信息
     */
   /* @RequiresPermissions("project:meal:remove")*/
    @Log(title = "套餐信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yqgSetMealService.deleteYqgSetMealByIds(ids));
    }
}
